package algorithm;

import java.util.ArrayList;
import java.util.List;

public class LetCode98 {

    public boolean isValidBST(TreeNode root) {
        List<Integer> list = new ArrayList<>();
        preTree(list, root);

        for (int i = 0; i < list.size() - 1; i++) {
            if (list.get(i) >= list.get(i+1)) {
                return false;
            }
        }
        return true;

    }

    public void preTree(List<Integer> list, TreeNode root) {
        if (root == null) {
            return;
        }
        preTree(list, root.left);
        list.add(root.val);
        preTree(list, root.right);
    }


    public static void main(String[] args) {

    }
}
